package dialog;

import android.content.Context;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.zx.theline.R;

import java.util.ArrayList;
import java.util.List;

import Utils.DictionariesUtil;
import app.MyApplication;
import base.BaseDialog;
import greendao.UserDao;
import greendao.entity.User;
import views.EditorGuardianView;

/**
 * Created by Ren on 2017/8/24.
 */

public class AddPersonDialog extends BaseDialog {

    private LinearLayout layout_jhr;
    private TextView btn_cancel, btn_confirm;
    //新增监护人View
    private EditorGuardianView mEditorGuardianView;
    private ArrayList<String> PersonList;


    public AddPersonDialog(Context context) {
        super(context, R.style.Theme_dialog);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_addperson);
        InitView();
        InitData();
        InitListen();
    }

    @Override
    protected void InitView() {
        layout_jhr = (LinearLayout) findViewById(R.id.layout_jhr);
        btn_confirm = (TextView) findViewById(R.id.btn_confirm);
        btn_cancel = (TextView) findViewById(R.id.btn_cancel);



    }

    @Override
    protected void InitData() {
        if(PersonList==null){
            PersonList=new ArrayList<>();
        }
       List<User>  mList = MyApplication.getDaoSession().getUserDao().queryBuilder().where(UserDao.Properties.LjyyxDwxxId.eq(MyApplication.getmLoginUser().getUserUnitId())).list();
        for (User mUser : mList) {
            PersonList.add(mUser.getLjyyxWorkerName());
        }
        mEditorGuardianView = new EditorGuardianView(getContext(), PersonList);
        layout_jhr.addView(mEditorGuardianView);
    }

    @Override
    protected void InitListen() {

    }
}
